package cn.liuhuan1.blogsModel.controller;


import cn.liuhuan1.entity.PageResult;
import cn.liuhuan1.entity.ReturnResult;
import cn.liuhuan1.webModelBean.api.SlideshowImp;
import cn.liuhuan1.webModelBean.bo.SlideshowBo;
import cn.liuhuan1.webModelBean.bo.WebListBo;
import cn.liuhuan1.webModelBean.vo.SlideshowVo;
import cn.liuhuan1.webModelBean.vo.WebListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/slideshow")
public class SlideshowController {

    @Autowired
    private SlideshowImp slideshowImp;

    @RequestMapping(value = "/getSlideshow",method = RequestMethod.GET)
    @ResponseBody
    public ReturnResult getSlideshow(){
        List<SlideshowVo> getSlideshow = slideshowImp.getSlideshow();
        return ReturnResult.succes(getSlideshow);
    }


    @RequestMapping(value = "/getPageSlideShow",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult getPageSlideShow(@RequestBody SlideshowBo slideshowBo){
        PageResult<SlideshowVo> pageResult =  slideshowImp.getPageSlideShow(slideshowBo);
        return ReturnResult.succes(pageResult);
    }

    @RequestMapping(value = "/delSlideShow",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult delSlideShow(@RequestParam("id") String id){
        slideshowImp.delSlideShow(id);
        return ReturnResult.succes();
    }

    @RequestMapping(value = "/saveSlideShow",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult saveSlideShow(@RequestBody SlideshowBo slideshowBo){
        slideshowImp.saveSlideShow(slideshowBo);
        return ReturnResult.succes();
    }

    @RequestMapping(value = "/getSlideShowById",method = RequestMethod.GET)
    @ResponseBody
    public ReturnResult getSlideShowById(@RequestParam("id") String id){
        SlideshowVo slideshowVo = slideshowImp.getSlideShowById(id);
        return ReturnResult.succes(slideshowVo);
    }

    @RequestMapping(value = "/updateSlideShow", method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult updateSlideShow(@RequestBody SlideshowBo slideshowBo){
        slideshowImp.updateSlideShow(slideshowBo);
        return ReturnResult.succes();
    }

}
